<template>
  <div class="container vipint">
    <div class="header">
      <div class="head-portrait">
        <img src="../assets/image/other/user.png" alt="" />
      </div>
      <div class="right">
        <div class="right-top">
          <p>{{ phone | rouding }}</p>
        </div>
        <div class="right-bottom">
          <div class="col">
            <img src="../assets/image/other/下载 (5).png" alt="" />
            <span>可用积分0</span>
          </div>
          <div class="col">
            <img src="../assets/image/other/下载 (2).png" alt="" />
            <span>冻结积分0</span>
          </div>
          <div class="col">
            <button><span> 积分记录</span></button>
          </div>
        </div>
      </div>
    </div>
    <div class="main">
      <div class="title">获取积分</div>
      <div class="content">
        <div class="content-left">
          <div class="first">可用经验值: <span>0</span></div>
          <div class="second">
            请输入兑换数量:
            <input type="text" />
            <div class="tips">必须为10的倍数进行兑换</div>
          </div>

          <div class="third">经验值兑换积分: <span>0</span></div>
          <div class="fourth">
            <button>立即兑换</button>
          </div>
        </div>
        <div class="content-right">
          <div class="item">
            <div>
              <img src="../assets/image/other/下载 (3).png" alt="" />
              <span>官方渠道购机即可获得积分</span>
            </div>
            <router-link to="/">
              <button>去购买</button>
            </router-link>
          </div>
          <div class="item">
            <div>
              <img src="../assets/image/other/下载 (3).png" alt="" />
              <span>官方渠道购机即可获得积分</span>
            </div>
            <router-link to="/">
              <button>去购买</button>
            </router-link>
          </div>
          <div class="item">
            <div>
              <img src="../assets/image/other/下载 (3).png" alt="" />
              <span>官方渠道购机即可获得积分</span>
            </div>
            <router-link to="/">
              <button>去购买</button>
            </router-link>
          </div>
        </div>
      </div>
    </div>
    <div class="exchange">
      <div class="title">积分兑换</div>
      <div class="exchange-main">
        <div class="item" v-for="(item, index) in showList" :key="index">
          <div class="content">
            <div class="img">
              <img
                v-lazy="item.s_goods_photos[0].path"
                :title="item.desc.split('-')[0]"
                alt=""
              />
            </div>
            <p>{{ item.desc.split("-")[0] }}</p>
            <div class="item-content">
              <div class="left">
                <span>500</span>积分+<span>{{ item.sale_price }}</span
                >元
              </div>
              <div class="right">
                <div>市场价</div>
                <div>￥{{ item.sale_price }}</div>
              </div>
            </div>
            <button>立即兑换</button>
          </div>
        </div>
      </div>
      <p @click="getMore" v-if="count < peijianShow.length">查看更多</p>
    </div>
  </div>
</template>

<script>
import { getUser } from "../assets/js/request.js";
import { mapGetters, mapActions } from "vuex";
export default {
  data() {
    return {
      count: 12,
      phone: "",
    };
  },
  computed: {
    ...mapGetters("products", ["peijianShow"]),
    showList() {
      return this.peijianShow.slice(0, this.count);
    },
  },
  methods: {
    ...mapActions("products", ["getProducts"]),
    getMore() {
      if (this.count < this.peijianShow.length) {
        this.count += 12;
      }
    },
  },
  async created() {
    this.getProducts();
    let res = await getUser();
    this.phone = res.phone;
  },
  filters: {
    rouding(value) {
      return value.replace(value.substring(3, 7), "****");
    },
  },
};
</script>

<style lang="scss">
@mixin flex_al {
  display: flex;
  align-items: center;
}
.container.vipint {
  color: #253746;
  padding-bottom: 40px;
  .header {
    @include flex_al;
    background-color: #fff;
    border-radius: 10px;
    margin-top: 40px;
    padding: 40px;
    .head-portrait {
      img {
        display: block;
        width: 90px;
        border-radius: 50%;
        height: 90px;
      }
    }
    .right {
      margin-left: 30px;
      width: 100%;
      .right-top {
        p {
          font-size: 20px;
        }
      }
      .right-bottom {
        @include flex_al;
        margin-top: 20px;
        .col {
          img {
            vertical-align: middle;
            margin-right: 10px;
          }
          & ~ .col {
            margin-left: 60px;
          }
          button {
            padding: 5px 15px;
            background-image: linear-gradient(90deg, #f4d9a9, #cea76c);
            white-space: nowrap;
            font-size: 0.8em;
            border-radius: 99px;
            text-align: center;
            outline: none;
            font-weight: 500;
            border: 1px solid transparent;
          }
        }
      }
    }
  }
  .main {
    border-radius: 10px;
    background-color: #fff;
    margin-top: 20px;
    color: #253746;
    padding: 40px;
    font-size: 15px;
    .title {
      text-align: center;
      font-size: 25px;
    }
    .content {
      padding: 30px 20px;
      font-size: 15px;
      @include flex_al;
      align-items: stretch;
      justify-content: space-between;
      .content-left {
        border: 1px solid #ccc;
        border-radius: 10px;
        padding: 30px;
        width: 350px;
        display: flex;
        flex-direction: column;
        & > div {
          margin: 10px 0;
          .tips {
            font-size: 12px;
            color: #999;
          }
          input {
            width: 100px;
            padding-left: 10px;
            margin-left: 20px;
            outline: none;
            border: 2px solid #fc0;
            line-height: 2;
            border-radius: 5px;
          }
        }
        .fourth {
          text-align: center;
          button {
            width: 120px;
            padding: 5px 15px;
            background-image: linear-gradient(90deg, #f4d9a9, #cea76c);
            white-space: nowrap;
            font-size: 0.8em;
            border-radius: 99px;
            text-align: center;
            outline: none;
            font-weight: 500;
            border: 1px solid transparent;
          }
        }
      }
      .content-right {
        width: 730px;
        border: 1px solid #ccc;
        border-radius: 10px;
        box-sizing: border-box;
        padding: 30px;
        @include flex_al;
        flex-direction: column;
        justify-content: space-around;
        .item {
          width: 100%;
          height: 40px;
          @include flex_al;
          justify-content: space-between;
          img {
            width: 36px;
            height: 36px;
            vertical-align: middle;
          }
          span {
            padding: 0 20px;
          }
          button {
            width: 120px;
            padding: 5px 15px;
            background-image: linear-gradient(90deg, #f4d9a9, #cea76c);
            white-space: nowrap;
            font-size: 0.8em;
            border-radius: 99px;
            text-align: center;
            outline: none;
            font-weight: 500;
            border: 1px solid transparent;
          }
        }
      }
    }
  }
  .exchange {
    border-radius: 10px;
    background-color: #fff;
    margin-top: 20px;
    color: #253746;
    padding: 40px;
    .title {
      text-align: center;
      font-size: 25px;
      margin: 15px 0 25px;
    }
    .exchange-main {
      display: flex;
      flex-wrap: wrap;
      justify-content: space-around;
      .item {
        width: 25%;
        padding: 20px;
        .content {
          height: 418px;
          box-sizing: border-box;
          border: 1px solid #ccc;
          border-radius: 10px;
          padding: 0 20px;
          padding-bottom: 10px;
          text-align: center;
          overflow: hidden;
          .img {
            margin-top: 34px;
            margin-bottom: 28px;
            img {
              width: 200px;
              height: 200px;
            }
          }
          p {
            text-align: center;
            word-break: break-all;
            height: 2em;
            line-height: 1em;
            overflow: hidden;
            text-overflow: ellipsis;
            font-size: 15px;
            white-space: nowrap;
          }
          .item-content {
            @include flex_al;
            justify-content: space-between;
            .right {
              font-size: 12px;
              color: #999;
            }
          }
          button {
            width: 100px;
            line-height: 2;
            padding: 0 15px;
            margin: 20px auto;
            background-image: linear-gradient(90deg, #f4d9a9, #cea76c);
            white-space: nowrap;
            font-size: 0.8em;
            border-radius: 99px;
            cursor: pointer;
            outline: none;
            font-weight: 500;
            border: 1px solid transparent;
          }
        }
      }
    }
    p {
      text-align: center;
      font-size: 14px;
      cursor: pointer;
    }
  }
}
</style>